﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MPlusTree;

namespace TestMPlusTree
{
    public class Key : MPKey
    {
        private int value;

        public int GetKeyValue()
        {
            return value;
        }

        public void SetKeyValue(int value)
        {
            this.value = value;
        }

        public override float Distance(MPKey k)
        {
            return Math.Abs(value - ((Key)k).GetKeyValue());
        }

        public override byte[] ToBytes()
        {
            return BitConverter.GetBytes(value);
        }

        public override void LoadFrom(byte[] b, int startIndex)
        {
            value = BitConverter.ToInt32(b, startIndex);
        }

        public override int Size()
        {
            return sizeof(int);
        }

        public override int GetDNO()
        {
            return 0;
        }

        public override void SetDNO(int k)
        {
            return;
        }

        public override float GetDimensionValue(int d)
        {
            return value;
        }

        public override MPKey Clone()
        {
            Key k = new Key();
            k.SetKeyValue(value);
            return k;
        }

        public override int SetUpDNO(MPKey[] keys)
        {
            return 0;
        }

        public override int SetUpDNO(LinkedList<float[]> keys)
        {
            return 0;
        }

        public override int SetUpDNO(LinkedList<MPKey> keys)
        {
            return 0;
        }
    }
}
